package fr.ece.si.ing5.madboomview;

import fr.ece.si.ing5.madboom.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Button;

public class GameMenu extends Activity implements OnClickListener,
		OnTouchListener {
	private Button newGameButton = null;
	private Button rulesButton = null;
	private Button quitButton = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_menu);

		newGameButton = (Button) findViewById(R.id.newGame_button);
		rulesButton = (Button) findViewById(R.id.rules_button);
		quitButton = (Button) findViewById(R.id.quit_button);

		newGameButton.setOnClickListener(this);
		newGameButton.setOnTouchListener(this);
		rulesButton.setOnClickListener(this);
		rulesButton.setOnTouchListener(this);
		quitButton.setOnClickListener(this);
		quitButton.setOnTouchListener(this);
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		switch (v.getId()) {
		case R.id.newGame_button:
			newGameButton.setBackground(getResources().getDrawable(
					R.drawable.new_game_button2));
			break;

		case R.id.rules_button:
			rulesButton.setBackground(getResources().getDrawable(
					R.drawable.rules_button2));
			break;

		case R.id.quit_button:
			quitButton.setBackground(getResources().getDrawable(
					R.drawable.quit_button2));
			break;
		}
		return false;
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.newGame_button:
			Intent intentPlay = new Intent(GameMenu.this, GamePlay.class);
			startActivity(intentPlay);
			newGameButton.setBackground(getResources().getDrawable(
					R.drawable.new_game_button));
			break;

		case R.id.rules_button:
			Intent intentRules = new Intent(GameMenu.this, GameRules.class);
			startActivity(intentRules);
			rulesButton.setBackground(getResources().getDrawable(
					R.drawable.rules_button));
			break;

		case R.id.quit_button:
			finish();
			quitButton.setBackground(getResources().getDrawable(
					R.drawable.quit_button));
			break;
		}
	}
}
